#define BOOST_TEST_MODULE MySuiteTest
#include <boost/test/included/unit_test.hpp>

#include <iostream>

#include "frreport_comm.h"
#include "frct_comm.h"
#include "frservice_comm.h"
#include "config.h"
#include "frmem_stat.h"
#include "frmem.h"
#include "pop3.h"

//pop3_detect
/* test_suite1 start */
BOOST_AUTO_TEST_SUITE(test_suite1)
// test_case1 in test_suite1
BOOST_AUTO_TEST_CASE(test_case1)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;

    fr_slab_init(102400, "ut_test");
	i_ret = pop3_detect(p_st_conn, p_st_packet);
	BOOST_REQUIRE_EQUAL(i_ret, APM_L7_IS_NO);
}
// test_case2 in test_suite1
BOOST_AUTO_TEST_CASE(test_case2)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;

	p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
	assert(p_st_conn);
	memset(p_st_conn, 0x00, sizeof(Conntrack));

	p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
	assert(p_st_packet);
	memset(p_st_packet, 0x00, sizeof(Apm_packet));
	p_st_packet->p_payload = (char *)"-ERR\r\n";
	p_st_packet->ui_payload_len = 6;

	i_ret = pop3_detect(p_st_conn, p_st_packet);
	BOOST_REQUIRE_EQUAL(i_ret, APM_L7_IS_NO);

	frfree(p_st_conn);
    frfree(p_st_packet);
}
// test_case3 in test_suite1
BOOST_AUTO_TEST_CASE(test_case3)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;

	p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
	assert(p_st_conn);
	memset(p_st_conn, 0x00, sizeof(Conntrack));

	p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
	assert(p_st_packet);
	memset(p_st_packet, 0x00, sizeof(Apm_packet));
	p_st_packet->p_payload = (char *)"+OK 1 56519\r\n";
	p_st_packet->ui_payload_len = 13;

	i_ret = pop3_detect(p_st_conn, p_st_packet);
	BOOST_REQUIRE_EQUAL(i_ret, APM_L7_IS_YES);

	frfree(p_st_conn);
	frfree(p_st_packet);
}
// test_case4 in test_suite1
BOOST_AUTO_TEST_CASE(test_case4)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;

	p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
	assert(p_st_conn);
	memset(p_st_conn, 0x00, sizeof(Conntrack));

	p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    assert(p_st_packet);
	memset(p_st_packet, 0x00, sizeof(Apm_packet));
	p_st_packet->p_payload = (char *)"+OO 1 56519\r\n";
	p_st_packet->ui_payload_len = 13;

	i_ret = pop3_detect(p_st_conn, p_st_packet);
	BOOST_REQUIRE_EQUAL(i_ret, APM_L7_IS_NO);

	frfree(p_st_conn);
	frfree(p_st_packet);

	fr_slab_destroy();
}
BOOST_AUTO_TEST_SUITE_END()
/* test_suite1 end */